# 在 schemas.py 或其他合适的位置
from typing import Any,Optional

from pydantic import BaseModel, Field

# 定义认证相关的请求/响应模型

class TokenData(BaseModel):
    access_token: str
    refresh_token: str
    token_type: str


class LoginTokenResponse(BaseModel):
    code: int
    msg: str
    data: TokenData


# 不包裹的返回结构
class LoginResponse(BaseModel):
    code: int
    msg: str
    data: Any
    access_token: Optional[str] = None
    refresh_token: Optional[str] = None
    token_type: Optional[str] = None


class Token(BaseModel):
    """令牌响应模型"""
    access_token: str
    refresh_token: str
    token_type: str = "bearer"


class RefreshRequest(BaseModel):
    """刷新令牌请求"""
    refresh_token: str = Field(..., description="刷新令牌")


class AuthRequest(BaseModel):
    """认证请求模型"""
    token: str = Field(..., description="访问令牌或刷新令牌")


class LoginRequest(BaseModel):
    """登录请求模型"""
    username: str = Field(..., description="用户名")
    password: str = Field(..., description="密码")
